/**
 * Created by dongp on 2018/1/20.
 */
$(function (){

    ini();
    save();
    cancel();

});

function ini() {
    var obj = $("#roleList").datagrid("getSelected");
    $('#tt').tree({
        url:"/admin/role/queryRoleResource?id="+obj.id,
        checkbox:function(node){
                return true;
        },
        loadFilter: function(data) {
            if(data.retData) {
                return data.retData.rows;
            }
        }
    });
}

function save(){

    $("#bind_save").on("click",function (){

        // var nodes = $('#tt').tree('getChecked');
        var nodes = $('#tt').tree('getChecked', ['checked','unchecked']);
        console.log(nodes)

        ui.request({
            url:"/admin/role/sss",
            data:sendData,
            success:function (rtn) {
                console.log(rtn)
                if(rtn.code != undefined && rtn.code !== "0000"){
                    $.messager.alert(rtn.msg,rtn.desc);
                }
                $('#win').window('close');
                $("#roleList").datagrid("reload",{});
            }
        })
    });
}

function cancel() {
    $("#bind_cancel").on("click",function (){
        $('#win').window('close');
    });
}